package com.atguigu.tingshu.album.controller;

import com.atguigu.tingshu.album.service.AlbumInfoService;
import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.common.util.AuthContextHolder;
import com.atguigu.tingshu.model.album.AlbumInfo;
import com.atguigu.tingshu.query.album.AlbumInfoQuery;
import com.atguigu.tingshu.vo.album.AlbumInfoVo;
import com.atguigu.tingshu.vo.album.AlbumListVo;
import com.atguigu.tingshu.vo.album.AlbumStatVo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "专辑管理")
@RestController
@RequestMapping("admin/album/albumInfo")
@SuppressWarnings({"all"})
public class AlbumInfoController {

    @Autowired
    private AlbumInfoService albumInfoService;

    @Operation(summary = "删除专辑信息")
    @DeleteMapping("removeAlbumInfo/{id}")
    public Result removeAlbumInfoById(@PathVariable Long id) {
        albumInfoService.removeAlbumInfoById(id);
        return Result.ok();
    }
    @Operation(summary = "获取专辑信息")
    @GetMapping("getAlbumInfo/{id}")
    public Result<AlbumInfo> getAlbumInfoById(@PathVariable Long id) {
        //	调用服务层方法
        AlbumInfo albumInfo = albumInfoService.getAlbumInfoById(id);
        return Result.ok(albumInfo);
    }
    @Operation(summary = "修改专辑")
    @PutMapping("/updateAlbumInfo/{id}")
    public Result updateById(@PathVariable Long id,@RequestBody @Validated AlbumInfoVo albumInfoVo){
        //	调用服务层方法
        albumInfoService.updateAlbumInfo(id,albumInfoVo);
        return Result.ok();
    }

    @Operation(summary = "获取当前用户全部专辑列表")
    @GetMapping("findUserAllAlbumList")
    public Result findUserAllAlbumList() {
        //	调用服务层方法
        List<AlbumInfo> list = albumInfoService.findUserAllAlbumList(AuthContextHolder.getUserId());
        return Result.ok(list);
    }

    @Operation(summary = "获取到专辑统计信息")
    @GetMapping("/getAlbumStatVo/{albumId}")
    public Result getAlbumStatVo(@PathVariable Long albumId){
        //	获取服务层方法
        AlbumStatVo albumStatVo = this.albumInfoService.getAlbumStatVoByAlbumId(albumId);
        return Result.ok(albumStatVo);
    }
}

